package br.com.clinica.supercao.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import br.com.clinica.supercao.entity.domain.EnumTipoAnimal;
import br.com.rpteixeira.entity.AbstractEntity;
@Entity
@Table(name="ANIMAIS",schema="clinica")
public class Animal extends AbstractEntity {
	private static final long serialVersionUID = 1L;
	
	private String nome;
	private String especie;
	private EnumTipoAnimal tipoAnimal;
	private Pessoa dono;
	private List<Consulta> consultas;
	@Override
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ANIMAL_GENERATOR")
	@SequenceGenerator(name = "ANIMAL_GENERATOR", sequenceName = "clinica.animal_seq", initialValue = 1, allocationSize = 1)
	@Column(name="SEQ_ANIMAL")
	public Integer getId() {
		return this.id;
	}
	
	@Column(name="DESC_NOME_ANIMAL",length=255)
	public String getNome() {
		return nome;
	}


	public void setNome(String nome) {
		this.nome = nome;
	}

	@Column(name="DESC_ESPECIE_ANIMAL",length=255)
	public String getEspecie() {
		return especie;
	}


	public void setEspecie(String especie) {
		this.especie = especie;
	}

	@Enumerated(value=EnumType.STRING)
	@Column(name="TIPO_ANIMAL",length=50)
	public EnumTipoAnimal getTipoAnimal() {
		return tipoAnimal;
	}
	public void setTipoAnimal(EnumTipoAnimal tipoAnimal) {
		this.tipoAnimal = tipoAnimal;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="SEQ_PESSOA_ID", referencedColumnName="SEQ_PESSOA")
	public Pessoa getDono() {
		return dono;
	}

	public void setDono(Pessoa dono){
		this.dono = dono;
	}
	@OneToMany(mappedBy="animal",fetch=FetchType.EAGER)
	public List<Consulta> getConsultas() {
		return consultas;
	}

	public void setConsultas(List<Consulta> consultas) {
		this.consultas = consultas;
	}
	
	@Transient
	public List<EnumTipoAnimal> getTipos(){
		return EnumTipoAnimal.getList();
	}
}
